﻿@{
    ViewBag.Title = "加工单列表";
    Layout = "~/Views/Shared/_LayoutList.cshtml"; 
}
@(       
 Html.nbGridFor<MaterialProcess>(s =>
 {
     s.Action("List");
     s.ExtParam(new { date = DateTime.Today.AddDays(1) });
     s.Columns(c =>
     {
         c.Bind(e => e.Id).IsKey();
         c.BindDateTime(e => e.ProcessDate).Width(70).AsSearch();
         c.Bind(e => e.TotalWeight).Width(50).Align(GridAlign.Right).AsSearch();
         c.BindEnum(e => e.OrderState, "ProcessState").Width(40);
         c.Bind(e => e.ItemDesc).Width("auto").Align(GridAlign.Left).AsSearch().AsQuery();
         c.Bind(e => e.UpdateUser).Width(60);
         c.BindDateTime(e => e.UpdateDate).Width(70);
         c.BindTemplate(260)
            .Template(@<a href="@Url.Action("Export")?id=${Id}" target="_blank" class="imgbtn2"><span
                class="print">打印</span></a>)
            .Template(@<a href="javascript:PickingItem('${Id}','${OrderState}')" class="imgbtn2"><span
                class="accept">领料</span></a>)
            .Template(@<a href="javascript:StorageItem('${Id}','${OrderState}')" class="imgbtn2"><span
                class="accept">入库</span></a>)
            .Template(Url.GridRowEditLink("编辑加工单"))
            .Template(@<a href="javascript:DeleteItem('${Id}','${OrderState}')" class="imgbtn2"><span
                class="Delete">删除</span></a>);

     });
     s.Buttons(b =>
     {
         b.Bind(GridButtonType.Add);
     });
 }))
<script type="text/javascript">
    function DeleteItem(id, state) {
        if (state != "Draft") {
            alert("加工单状态已经不是草稿了，不能删除！");
        }
        else {
            DeleteRecord('@Url.Action("Delete")?id=' + id, "该加工单")
        }
    }
    function StorageItem(id, state) {
        if (state != "Picking") {
            alert("加工单状态不是领料，不能入库！");
        }
        else {
            OpenModalDialog('@Url.Action("Storage")?Id=' + id,
            {
                caption: "加工入库单",
                width: 610,
                height: 450,
                onclose: refreshGrid
            });
        }
    }
    function PickingItem(id, state) {
        if (state != "Draft") {
            alert("加工单状态不是草稿，不能领料！");
        }
        else {
            OpenModalDialog('@Url.Action("Picking")?Id=' + id,
            {
                caption: "加工领料单",
                width: 610,
                height: 450,
                onclose: refreshGrid
            });
        }
    }
</script>
